package com.xyongfeng.foodManagement.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xyongfeng.foodManagement.domain.group.AddGroup;
import com.xyongfeng.foodManagement.domain.group.NormalGroup;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * 
 * @TableName food_in_info
 */
@TableName(value ="t_food_in_info")
@Data
public class FoodInInfo implements Serializable {
    /**
     * 入库单号
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String inId;

    /**
     * 食品编号
     */
    private Integer inFoodId;

    /**
     * 入库数量
     */
    @Min(value = 0, message = "入库数量不能为负数", groups = {NormalGroup.class})
    @NotNull(message = "入库数量不能为空", groups = {AddGroup.class})
    private Integer inNum;

    /**
     * 入库时间
     */
    private String inTime;

    /**
     * 管理员工号
     */
    private Integer inAdminId;


    /**
     * 管理员工信息
     */
    @TableField(exist = false)
    private AdminInfo adminInfo;

    /**
     * 食品信息
     */
    @TableField(exist = false)
    private FoodInfo foodInfo;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        FoodInInfo other = (FoodInInfo) that;
        return (this.getInId() == null ? other.getInId() == null : this.getInId().equals(other.getInId()))
            && (this.getInFoodId() == null ? other.getInFoodId() == null : this.getInFoodId().equals(other.getInFoodId()))
            && (this.getInNum() == null ? other.getInNum() == null : this.getInNum().equals(other.getInNum()))
            && (this.getInTime() == null ? other.getInTime() == null : this.getInTime().equals(other.getInTime()))
            && (this.getInAdminId() == null ? other.getInAdminId() == null : this.getInAdminId().equals(other.getInAdminId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getInId() == null) ? 0 : getInId().hashCode());
        result = prime * result + ((getInFoodId() == null) ? 0 : getInFoodId().hashCode());
        result = prime * result + ((getInNum() == null) ? 0 : getInNum().hashCode());
        result = prime * result + ((getInTime() == null) ? 0 : getInTime().hashCode());
        result = prime * result + ((getInAdminId() == null) ? 0 : getInAdminId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", inId=").append(inId);
        sb.append(", inFoodId=").append(inFoodId);
        sb.append(", inNum=").append(inNum);
        sb.append(", inTime=").append(inTime);
        sb.append(", inAdminId=").append(inAdminId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}